#速度测试
import time,datetime,random

messages=[
    "Of all the trees we clould've hit, we had to get one that hits back. ",
    "If he doesn't stop trying to save your life he's going to kill you.",
    "It is our choiecs that show what we truly are, far more than our abilities."
    "I am a wizard, not a baboon brandishing a stick."
    "Greatness inspires envy, envy engenders spite, spite spawns lies."
    "In dreams,we enter a world that's entirely our own."
    "It is my belief thata the truth is generally preferable to lies."
    "Dawn seemed to follow midnight with indecent haste."
]

print('打字速度测试，跟随提示的消息进行打字，将会记录你的打字时间：')
time.sleep(2)
print('\n准备。。。')
time.sleep(1)
print('\n开始')
message=random.choice(messages)
print('\n',message)
startTime=datetime.datetime.now()   #启动时钟
typing=input('>')
endTime=datetime.datetime.now()     #停止时钟
diff=endTime-startTime
typingTime=diff.seconds+diff.microseconds/float(1000000)
cps=len(message)/typingTime
wpm=cps*60/5.0
print('\n你打印[%i]字符花费了[%.1f]秒。'%(len(message),typingTime))

print('\n每秒打印[%.2f]字符，或者每分钟打印[%.1f]字符。'%(cps,wpm))
if typing==message:
    print('\n 你没有打错任何字符')
else:
    print("\n很遗憾，你最少打印错了一个字符")